# -*- coding: utf-8 -*-

import scrapy
from fangtianxia.items import FangtianxiaItem

class FangSpider(scrapy.Spider):
    name = 'FangSpider'
    allowed_domains = ['https://cd.fang.com/']
    start_urls = ['https://cd.fang.com/']
    base_domain = 'https://cd.newhouse.fang.com'

    def parse(self, response):
        Proj_Categary = response.xpath('//*[@class="nlcd_name"]/a/text()').getall()
        Image_Urls = response.xpath('//*[@class="nlc_img"]/a//@src').getall()
        Proj_Loc = response.xpath('//*[@class="address"]/a//@title').getall()
        Proj_Price = response.xpath('//*[@class="nhouse_price"]/span/text()').getall()
        item = FangtianxiaItem(Proj_Categary=Proj_Categary,image_urls=Image_Urls,Proj_Loc=Proj_Loc,Proj_Price=Proj_Price)
        yield item